package by.myteam.library.storage;

import java.util.ArrayList;
import java.util.List;

import by.myteam.library.storage.db.DbStorageProvider;
import by.myteam.library.storage.file.FileStorageProvider;
import by.myteam.library.storage.st.StaticStorageProvider;

public class StorageFactory {

	private static StorageFactory factory;
	
	private List<IStorageProvider> listStorageProviders;
	
	public static enum StorageType {
		
		STATIC(new StaticStorageProvider()), 
		
		FILE(new FileStorageProvider()), 
		
		DB(new DbStorageProvider());
		
		private IStorageProvider provider;
		
		StorageType(IStorageProvider provider) {
			this.provider = provider;
		}
		
		public IStorageProvider getProvider() {
			return this.provider;
		}
		
	}
	
	private StorageFactory() {
		listStorageProviders = new ArrayList<IStorageProvider>();
		StorageType[] values = StorageType.values();
		for (StorageType storageType : values) {
			listStorageProviders.add(storageType.getProvider());	
		}
	}
	
	public static StorageFactory getFactory() {
		if (factory == null) {
			factory = new StorageFactory();
		}
		return factory;
	}
	
	public List<IStorageProvider> getListStorageProviders() {
		return listStorageProviders;
	}
	
}
